<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>

<script>
    var now = new Date();
    console.log(now);
    console.log(now.getFullYear());     //年
    console.log(now.getMonth());        //月 0~11
    console.log(now.getDate());         //日
    console.log(now.getDay());          //星期几
    console.log(now.getHours());        //时
    console.log(now.getMinutes());      //分
    console.log(now.getSeconds());      //秒

    console.log(now.getTime());     // 时间戳 全世界统一 1970 1.1 0：:0:00 毫秒数
    console.log(new Date(1627996246475))   //把时间戳转换为时间

    // 获取本地时间,注意调用的是方法不是属性
    console.log( now.toLocaleString());
    // 获取北京时间
    console.log(new Date(1627996246475).toGMTString())
</script>

</body>
</html>